package day04;

import java.util.Random;
import java.util.Scanner;

public class ForDemo {
    public static void main(String[] args) {
        getSum();


    }
    public static void getSum(){
        Scanner sc = new Scanner(System.in);
        Random r = new Random();
        int sum = 0;
        for (int i = 0; i < 5; i++) {
            int num1 = r.nextInt(100)+1;
            int num2 = r.nextInt(100)+1;
            System.out.println(num1 +"+"+num2+"=?");
            System.out.println("请输入你的答案");
            int userAnswer = sc.nextInt();

            if (userAnswer == (num1 + num2)){
                System.out.println("回答正确");
                sum = sum +10;
            }else {
                System.out.println("回答错误，下一题是");
            }

        }
        System.out.println("你的最终得分是"+sum+"分");
    }
}
/*int sum = 0;
        for (int i = 0; i <= 100; i++) {
            sum = sum + i;
        }
        System.out.println(sum);*/